package com.wondertek.applet.controller.business;

import com.wondertek.common.base.Result;
import com.wondertek.service.dto.app.req.HomePageDateReq;
import com.wondertek.service.dto.app.res.HomePageRoomRes;
import com.wondertek.service.dto.app.res.HomePageTopRes;
import com.wondertek.service.dto.app.res.HomePageTrendRes;
import com.wondertek.service.dto.app.res.HomePageTypeRes;
import com.wondertek.service.service.business.HomePageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wangyu
 */
@RestController
@RequestMapping("/app/home/page/")
@Tag(name = "app首页")
public class HomePageController {

    @Autowired
    private HomePageService homePageService;

    @GetMapping("/findTop")
    @Operation(summary = "首页顶部数量查询")
    public Result<HomePageTopRes> findTop(){
        return Result.success(homePageService.findTop());
    }

    @GetMapping("/findRoom")
    @Operation(summary = "首页房间控制")
    public Result<List<HomePageRoomRes>> findRoom(){
        return Result.success(homePageService.findRoom());
    }

    @PostMapping("/findTrend")
    @Operation(summary = "首页报警趋势")
    public Result<List<HomePageTrendRes>> findTrend(@RequestBody @Validated HomePageDateReq homePageDateReq){
        return Result.success(homePageService.findTrend(homePageDateReq));
    }

    @PostMapping("/findTypeRatio")
    @Operation(summary = "首页类型分布")
    public Result<List<HomePageTypeRes>> findTypeRatio(@RequestBody @Validated HomePageDateReq homePageDateReq){
        return Result.success(homePageService.findTypeRatio(homePageDateReq));
    }


}
